package com.sj.purchase;

import com.sj.purchase.util.HttpsClientRequestFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Primary;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.web.client.RestTemplate;


@EnableScheduling
@SpringBootApplication
public class PurchaseApplication {

	@Autowired
	private RestTemplateBuilder builder;

	@Bean
	public RestTemplate httpsRestTemplate() {
		return builder.requestFactory(new HttpsClientRequestFactory()).build();
	}

	@Bean
	@Primary
	public RestTemplate restTemplate(){
		return new RestTemplate();
	}


	public static void main(String[] args) {
		SpringApplication.run(PurchaseApplication.class, args);
	}
}
